<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>tango.io.selector.model.ISelector</title>
  <link href="./css/style.css" rel="stylesheet" type="text/css"/>
  <!-- <link href="./img/icon.png" rel="icon" type="image/png"/> -->
  <script type="text/javascript" src="./js/jquery.js"></script>
  <script type="text/javascript" src="./js/modules.js"></script>
  <script type="text/javascript" src="./js/quicksearch.js"></script>
  <script type="text/javascript" src="./js/navigation.js"></script>
  <!--<script type="text/javascript" src="./js/jquery.treeview.js"></script>-->
  <script type="text/javascript">
    var g_moduleFQN = "tango.io.selector.model.ISelector";
  </script>
  
</head>
<body>
<div id="content">
  <h1><a href="./htmlsrc/tango.io.selector.model.ISelector.html" class="symbol">tango.io.selector.model.ISelector</a></h1>
  
<p class="sec_header">License:</p>BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a>
<p class="sec_header">Author:</p>Juan Jose Comellas <juanjo@comellas.com.ar>
<dl>
<dt class="decl">enum <a class="symbol _enum" name="Event" href="./htmlsrc/tango.io.selector.model.ISelector.html#L17" kind="enum" beg="17" end="31">Event</a>; <a title="Permalink to this symbol" href="#Event" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L17">#</a></dt>
<dd class="ddef">
<div class="summary">Events that are used to register a Conduit to a selector and are returned
 in a SelectionKey after calling ISelector.select().</div>
</dd>
<dt class="decl">class <a class="symbol _class" name="SelectionKey" href="./htmlsrc/tango.io.selector.model.ISelector.html#L51" kind="class" beg="51" end="182">SelectionKey</a>; <a title="Permalink to this symbol" href="#SelectionKey" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L51">#</a></dt>
<dd class="ddef">
<div class="summary">The SelectionKey class holds the information concerning the conduits and
 their association to a selector. Each key keeps a reference to a registered
 conduit and the events that are to be tracked for it. The 'events' member
 of the key can take two meanings, depending on where it's used. If used
 with the registration methods of the selector (register(), reregister()) it
 represents the events we want to track; if used within a foreach cycle
 on an ISelectionSet it represents the events that have been detected for a
 conduit.</div>
The SelectionKey can also hold an optional object via the 'attachment'
 member. This member is very convenient to keep application-specific data
 that will be needed when the tracked events are triggered.
<p class="bl"/>
 See <a href="tango.io.selector.ISelector">tango.io.selector.ISelector</a>,
 <a href="tango.io.selector.ISelectionSet">tango.io.selector.ISelectionSet</a>
<dl>
<dt class="decl"><a class="symbol _ctor" name="SelectionKey.this" href="./htmlsrc/tango.io.selector.model.ISelector.html#L60" kind="ctor" beg="60" end="62">this</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.this" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L60">#</a></dt>
<dd class="ddef">
<div class="summary">Constructor</div></dd>
<dt class="decl"><a class="symbol _ctor" name="SelectionKey.this:2" href="./htmlsrc/tango.io.selector.model.ISelector.html#L80" kind="ctor" beg="80" end="85">this</a><span class="params">(ISelectable <em>conduit</em>, Event <em>events</em>, Object <em>attachment</em> = null)</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.this:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L80">#</a></dt>
<dd class="ddef">
<div class="summary">Constructor</div>
<p class="sec_header">Params:</p>
<table class="params">
<tr><td><em>conduit</em></td><td>conduit that will be associated to this SelectionKey</td></tr>
<tr><td><em>events</em></td><td>events that will be tracked for the conduit</td></tr>
<tr><td><em>attachment</em></td><td>optional object with application-specific data that will
                be available when an event is triggered for the conduit</td></tr></table>
<p class="sec_header">Examples:</p><pre class="d_code">
<span class="i">SocketConduit</span> <span class="i">cond</span>;

<span class="k">auto</span> <span class="i">key</span> = <span class="k">new</span> <span class="i">SelectionKey</span>(<span class="i">cond</span>, <span class="i">Event</span>.<span class="i">Read</span> | <span class="i">Event</span>.<span class="i">Write</span>);
</pre></dd>
<dt class="decl">ISelectable <a class="symbol _function" name="SelectionKey.conduit" href="./htmlsrc/tango.io.selector.model.ISelector.html#L90" kind="function" beg="90" end="93">conduit</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.conduit" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L90">#</a></dt>
<dd class="ddef">
<div class="summary">Return the conduit held by the instance.</div></dd>
<dt class="decl">void <a class="symbol _function" name="SelectionKey.conduit:2" href="./htmlsrc/tango.io.selector.model.ISelector.html#L98" kind="function" beg="98" end="101">conduit</a><span class="params">(ISelectable <em>conduit</em>)</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.conduit:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L98">#</a></dt>
<dd class="ddef">
<div class="summary">Set the conduit held by the instance</div></dd>
<dt class="decl">Event <a class="symbol _function" name="SelectionKey.events" href="./htmlsrc/tango.io.selector.model.ISelector.html#L106" kind="function" beg="106" end="109">events</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.events" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L106">#</a></dt>
<dd class="ddef">
<div class="summary">Return the registered events as a bit mask of different Event values.</div></dd>
<dt class="decl">void <a class="symbol _function" name="SelectionKey.events:2" href="./htmlsrc/tango.io.selector.model.ISelector.html#L114" kind="function" beg="114" end="117">events</a><span class="params">(Event <em>events</em>)</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.events:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L114">#</a></dt>
<dd class="ddef">
<div class="summary">Set the registered events as a bit mask of different Event values.</div></dd>
<dt class="decl">Object <a class="symbol _function" name="SelectionKey.attachment" href="./htmlsrc/tango.io.selector.model.ISelector.html#L122" kind="function" beg="122" end="125">attachment</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.attachment" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L122">#</a></dt>
<dd class="ddef">
<div class="summary">Return the attached Object held by the instance.</div></dd>
<dt class="decl">void <a class="symbol _function" name="SelectionKey.attachment:2" href="./htmlsrc/tango.io.selector.model.ISelector.html#L130" kind="function" beg="130" end="133">attachment</a><span class="params">(Object <em>attachment</em>)</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.attachment:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L130">#</a></dt>
<dd class="ddef">
<div class="summary">Set the attached Object held by the instance</div></dd>
<dt class="decl">bool <a class="symbol _function" name="SelectionKey.isReadable" href="./htmlsrc/tango.io.selector.model.ISelector.html#L138" kind="function" beg="138" end="141">isReadable</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.isReadable" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L138">#</a></dt>
<dd class="ddef">
<div class="summary">Check if a Read event has been associated to this SelectionKey.</div></dd>
<dt class="decl">bool <a class="symbol _function" name="SelectionKey.isUrgentRead" href="./htmlsrc/tango.io.selector.model.ISelector.html#L146" kind="function" beg="146" end="149">isUrgentRead</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.isUrgentRead" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L146">#</a></dt>
<dd class="ddef">
<div class="summary">Check if an UrgentRead event has been associated to this SelectionKey.</div></dd>
<dt class="decl">bool <a class="symbol _function" name="SelectionKey.isWritable" href="./htmlsrc/tango.io.selector.model.ISelector.html#L154" kind="function" beg="154" end="157">isWritable</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.isWritable" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L154">#</a></dt>
<dd class="ddef">
<div class="summary">Check if a Write event has been associated to this SelectionKey.</div></dd>
<dt class="decl">bool <a class="symbol _function" name="SelectionKey.isError" href="./htmlsrc/tango.io.selector.model.ISelector.html#L162" kind="function" beg="162" end="165">isError</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.isError" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L162">#</a></dt>
<dd class="ddef">
<div class="summary">Check if an Error event has been associated to this SelectionKey.</div></dd>
<dt class="decl">bool <a class="symbol _function" name="SelectionKey.isHangup" href="./htmlsrc/tango.io.selector.model.ISelector.html#L170" kind="function" beg="170" end="173">isHangup</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.isHangup" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L170">#</a></dt>
<dd class="ddef">
<div class="summary">Check if a Hangup event has been associated to this SelectionKey.</div></dd>
<dt class="decl">bool <a class="symbol _function" name="SelectionKey.isInvalidHandle" href="./htmlsrc/tango.io.selector.model.ISelector.html#L178" kind="function" beg="178" end="181">isInvalidHandle</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>]</span> <a title="Permalink to this symbol" href="#SelectionKey.isInvalidHandle" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L178">#</a></dt>
<dd class="ddef">
<div class="summary">Check if an InvalidHandle event has been associated to this SelectionKey.</div></dd></dl></dd>
<dt class="decl">interface <a class="symbol _interface" name="ISelectionSet" href="./htmlsrc/tango.io.selector.model.ISelector.html#L191" kind="interface" beg="191" end="202">ISelectionSet</a>; <a title="Permalink to this symbol" href="#ISelectionSet" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L191">#</a></dt>
<dd class="ddef">
<div class="summary">Container that holds the SelectionKey's for all the conduits that have
 triggered events during a previous invocation to ISelector.select().
 Instances of this container are normally returned from calls to
 ISelector.selectedSet().</div>
<dl>
<dt class="decl">uint <a class="symbol _function" name="ISelectionSet.length" href="./htmlsrc/tango.io.selector.model.ISelector.html#L196" kind="function" beg="196" end="196">length</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#ISelectionSet.length" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L196">#</a></dt>
<dd class="ddef">
<div class="summary">Returns the number of SelectionKey's in the set.</div></dd>
<dt class="decl">int <a class="symbol _function" name="ISelectionSet.opApply" href="./htmlsrc/tango.io.selector.model.ISelector.html#L201" kind="function" beg="201" end="201">opApply</a><span class="params">(int delegate(inout SelectionKey) <em>dg</em>)</span>; <span class="attrs">[<span class="prot">public</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#ISelectionSet.opApply" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L201">#</a></dt>
<dd class="ddef">
<div class="summary">Operator to iterate over a set via a foreach block.</div></dd></dl></dd>
<dt class="decl">interface <a class="symbol _interface" name="ISelector" href="./htmlsrc/tango.io.selector.model.ISelector.html#L300" kind="interface" beg="300" end="460">ISelector</a>; <a title="Permalink to this symbol" href="#ISelector" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L300">#</a></dt>
<dd class="ddef">
<div class="summary">A selector is a multiplexor for I/O events associated to a Conduit.
 All selectors must implement this interface.</div>
A selector needs to be initialized by calling the open() method to pass
 it the initial amount of conduits that it will handle and the maximum
 amount of events that will be returned per call to select(). In both cases,
 these values are only hints and may not even be used by the specific
 ISelector implementation you choose to use, so you cannot make any
 assumptions regarding what results from the call to select() (i.e. you
 may receive more or less events per call to select() than what was passed
 in the 'maxEvents' argument. The amount of conduits that the selector can
 manage will be incremented dynamically if necessary.
<p class="bl"/>
 To add, modify or remove conduit registrations to the selector you use
 the register(), reregister() and unregister() methods respectively.
<p class="bl"/>
 To wait for events from the conduits you need to call any of the select()
 methods. The selector cannot be modified from another thread while
 blocking on a call to these methods.
<p class="bl"/>
 Once the selector is no longer used you must call the close() method so
 that the selector can free any resources it may have allocated in the call
 to open().
<p class="sec_header">Examples:</p><pre class="d_code">
<span class="k">import</span> <span class="i">tango</span>.<span class="i">io</span>.<span class="i">selector</span>.<span class="i">model</span>.<span class="i">ISelector</span>;
<span class="k">import</span> <span class="i">tango</span>.<span class="i">io</span>.<span class="i">SocketConduit</span>;
<span class="k">import</span> <span class="i">tango</span>.<span class="i">io</span>.<span class="i">Stdout</span>;

<span class="i">ISelector</span> <span class="i">selector</span>;
<span class="i">SocketConduit</span> <span class="i">conduit1</span>;
<span class="i">SocketConduit</span> <span class="i">conduit2</span>;
<span class="i">MyClass</span> <span class="i">object1</span>;
<span class="i">MyClass</span> <span class="i">object2</span>;
<span class="k">int</span> <span class="i">eventCount</span>;

<span class="lc">// Initialize the selector assuming that it will deal with 2 conduits and</span>
<span class="lc">// will receive 2 events per invocation to the select() method.</span>
<span class="i">selector</span>.<span class="i">open</span>(<span class="n">2</span>, <span class="n">2</span>);

<span class="i">selector</span>.<span class="i">register</span>(<span class="i">conduit</span>, <span class="i">Event</span>.<span class="i">Read</span>, <span class="i">object1</span>);
<span class="i">selector</span>.<span class="i">register</span>(<span class="i">conduit</span>, <span class="i">Event</span>.<span class="i">Write</span>, <span class="i">object2</span>);

<span class="i">eventCount</span> = <span class="i">selector</span>.<span class="i">select</span>();

<span class="k">if</span> (<span class="i">eventCount</span> &gt; <span class="n">0</span>)
{
    <span class="k">char</span>[<span class="n">16</span>] <span class="i">buffer</span>;
    <span class="k">int</span> <span class="i">count</span>;

    <span class="k">foreach</span> (<span class="i">SelectionKey</span> <span class="i">key</span>, <span class="i">selector</span>.<span class="i">selectedSet</span>())
    {
        <span class="k">if</span> (<span class="i">key</span>.<span class="i">isReadable</span>())
        {
            <span class="i">count</span> = (<span class="k">cast</span>(<span class="i">SocketConduit</span>) <span class="i">key</span>.<span class="i">conduit</span>).<span class="i">read</span>(<span class="i">buffer</span>);
            <span class="k">if</span> (<span class="i">count</span> != <span class="i">IConduit</span>.<span class="i">Eof</span>)
            {
                <span class="i">Stdout</span>.<span class="i">format</span>(<span class="sl">"Received '{0}' from peer\n"</span>, <span class="i">buffer</span>[<span class="n">0</span>..<span class="i">count</span>]);
                <span class="i">selector</span>.<span class="i">reregister</span>(<span class="i">key</span>.<span class="i">conduit</span>, <span class="i">Event</span>.<span class="i">Write</span>, <span class="i">key</span>.<span class="i">attachment</span>);
            }
            <span class="k">else</span>
            {
                <span class="i">selector</span>.<span class="i">unregister</span>(<span class="i">key</span>.<span class="i">conduit</span>);
                <span class="i">key</span>.<span class="i">conduit</span>.<span class="i">close</span>();
            }
        }

        <span class="k">if</span> (<span class="i">key</span>.<span class="i">isWritable</span>())
        {
            <span class="i">count</span> = (<span class="k">cast</span>(<span class="i">SocketConduit</span>) <span class="i">key</span>.<span class="i">conduit</span>).<span class="i">write</span>(<span class="sl">"MESSAGE"</span>);
            <span class="k">if</span> (<span class="i">count</span> != <span class="i">IConduit</span>.<span class="i">Eof</span>)
            {
                <span class="i">Stdout</span>.<span class="i">print</span>(<span class="sl">"Sent 'MESSAGE' to peer\n"</span>);
                <span class="i">selector</span>.<span class="i">reregister</span>(<span class="i">key</span>.<span class="i">conduit</span>, <span class="i">Event</span>.<span class="i">Read</span>, <span class="i">key</span>.<span class="i">attachment</span>);
            }
            <span class="k">else</span>
            {
                <span class="i">selector</span>.<span class="i">unregister</span>(<span class="i">key</span>.<span class="i">conduit</span>);
                <span class="i">key</span>.<span class="i">conduit</span>.<span class="i">close</span>();
            }
        }

        <span class="k">if</span> (<span class="i">key</span>.<span class="i">isError</span>() || <span class="i">key</span>.<span class="i">isHangup</span>() || <span class="i">key</span>.<span class="i">isInvalidHandle</span>())
        {
            <span class="i">selector</span>.<span class="i">unregister</span>(<span class="i">key</span>.<span class="i">conduit</span>);
            <span class="i">key</span>.<span class="i">conduit</span>.<span class="i">close</span>();
        }
    }
}

<span class="i">selector</span>.<span class="i">close</span>();
</pre>
<dl>
<dt class="decl">void <a class="symbol _function" name="ISelector.open" href="./htmlsrc/tango.io.selector.model.ISelector.html#L312" kind="function" beg="312" end="312">open</a><span class="params">(uint <em>size</em>, uint <em>maxEvents</em>)</span>; <span class="attrs">[<span class="prot">public</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#ISelector.open" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L312">#</a></dt>
<dd class="ddef">
<div class="summary">Initialize the selector.</div>
<p class="sec_header">Params:</p>
<table class="params">
<tr><td><em>size</em></td><td>value that provides a hint for the maximum amount of
                conduits that will be registered</td></tr>
<tr><td><em>maxEvents</em></td><td>value that provides a hint for the maximum amount of
                conduit events that will be returned in the selection
                set per call to select.</td></tr></table></dd>
<dt class="decl">void <a class="symbol _function" name="ISelector.close" href="./htmlsrc/tango.io.selector.model.ISelector.html#L323" kind="function" beg="323" end="323">close</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#ISelector.close" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L323">#</a></dt>
<dd class="ddef">
<div class="summary">Free any operating system resources that may have been allocated in the
 call to open().</div>
<p class="sec_header">Remarks:</p>Not all of the selectors need to free resources other than allocated
 memory, but those that do will normally also add a call to close() in
 their destructors.</dd>
<dt class="decl">void <a class="symbol _function" name="ISelector.register" href="./htmlsrc/tango.io.selector.model.ISelector.html#L345" kind="function" beg="345" end="346">register</a><span class="params">(ISelectable <em>conduit</em>, Event <em>events</em>, Object <em>attachment</em> = null)</span>; <span class="attrs">[<span class="prot">public</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#ISelector.register" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L345">#</a></dt>
<dd class="ddef">
<div class="summary">Associate a conduit to the selector and track specific I/O events.</div>
<p class="sec_header">Params:</p>
<table class="params">
<tr><td><em>conduit</em></td><td>conduit that will be associated to the selector;
                must be a valid conduit (i.e. not null and open).</td></tr>
<tr><td><em>events</em></td><td>bit mask of Event values that represent the events that
                will be tracked for the conduit.</td></tr>
<tr><td><em>attachment</em></td><td>optional object with application-specific data that will
                be available when an event is triggered for the conduit</td></tr></table>
<p class="sec_header">Examples:</p><pre class="d_code">
<span class="i">ISelector</span> <span class="i">selector</span>;
<span class="i">SocketConduit</span> <span class="i">conduit</span>;
<span class="i">MyClass</span> <span class="i">object</span>;

<span class="i">selector</span>.<span class="i">register</span>(<span class="i">conduit</span>, <span class="i">Event</span>.<span class="i">Read</span> | <span class="i">Event</span>.<span class="i">Write</span>, <span class="i">object</span>);
</pre></dd>
<dt class="decl">void <a class="symbol _function" name="ISelector.reregister" href="./htmlsrc/tango.io.selector.model.ISelector.html#L373" kind="function" beg="373" end="374">reregister</a><span class="params">(ISelectable <em>conduit</em>, Event <em>events</em>, Object <em>attachment</em> = null)</span>; <span class="attrs">[<span class="prot">public</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#ISelector.reregister" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L373">#</a></dt>
<dd class="ddef">
<div class="summary">Modify the events that are being tracked or the 'attachment' field
 for an already registered conduit.</div>
<p class="sec_header">Params:</p>
<table class="params">
<tr><td><em>conduit</em></td><td>conduit that will be associated to the selector;
                must be a valid conduit (i.e. not null and open).</td></tr>
<tr><td><em>events</em></td><td>bit mask of Event values that represent the events that
                will be tracked for the conduit.</td></tr>
<tr><td><em>attachment</em></td><td>optional object with application-specific data that will
                be available when an event is triggered for the conduit</td></tr></table>
<p class="sec_header">Remarks:</p>The 'attachment' member of the SelectionKey will always be overwritten,
 even if it's null.
<p class="sec_header">Examples:</p><pre class="d_code">
<span class="i">ISelector</span> <span class="i">selector</span>;
<span class="i">SocketConduit</span> <span class="i">conduit</span>;
<span class="i">MyClass</span> <span class="i">object</span>;

<span class="i">selector</span>.<span class="i">reregister</span>(<span class="i">conduit</span>, <span class="i">Event</span>.<span class="i">Write</span>, <span class="i">object</span>);
</pre></dd>
<dt class="decl">void <a class="symbol _function" name="ISelector.unregister" href="./htmlsrc/tango.io.selector.model.ISelector.html#L386" kind="function" beg="386" end="386">unregister</a><span class="params">(ISelectable <em>conduit</em>)</span>; <span class="attrs">[<span class="prot">public</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#ISelector.unregister" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L386">#</a></dt>
<dd class="ddef">
<div class="summary">Remove a conduit from the selector.</div>
<p class="sec_header">Params:</p>
<table class="params">
<tr><td><em>conduit</em></td><td>conduit that had been previously associated to the
                selector; it can be null.</td></tr></table>
<p class="sec_header">Remarks:</p>Unregistering a null conduit is allowed and no exception is thrown
 if this happens.</dd>
<dt class="decl">int <a class="symbol _function" name="ISelector.select" href="./htmlsrc/tango.io.selector.model.ISelector.html#L396" kind="function" beg="396" end="396">select</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#ISelector.select" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L396">#</a></dt>
<dd class="ddef">
<div class="summary">Wait indefinitely for I/O events from the registered conduits.</div>
<p class="sec_header">Returns:</p>The amount of conduits that have received events; 0 if no conduits
 have received events within the specified timeout and -1 if there
 was an error.</dd>
<dt class="decl">int <a class="symbol _function" name="ISelector.select:2" href="./htmlsrc/tango.io.selector.model.ISelector.html#L413" kind="function" beg="413" end="413">select</a><span class="params">(TimeSpan <em>timeout</em>)</span>; <span class="attrs">[<span class="prot">public</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#ISelector.select:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L413">#</a></dt>
<dd class="ddef">
<div class="summary">Wait for I/O events from the registered conduits for a specified
 amount of time.</div>
<p class="sec_header">Params:</p>
<table class="params">
<tr><td><em>timeout</em></td><td>TimeSpan with the maximum amount of time that the
            selector will wait for events from the conduits; the
            amount of time is relative to the current system time
            (i.e. just the number of milliseconds that the selector
            has to wait for the events).</td></tr></table>
<p class="sec_header">Returns:</p>The amount of conduits that have received events; 0 if no conduits
 have received events within the specified timeout.</dd>
<dt class="decl">int <a class="symbol _function" name="ISelector.select:3" href="./htmlsrc/tango.io.selector.model.ISelector.html#L439" kind="function" beg="439" end="439">select</a><span class="params">(double <em>timeout</em>)</span>; <span class="attrs">[<span class="prot">public</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#ISelector.select:3" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L439">#</a></dt>
<dd class="ddef">
<div class="summary">Wait for I/O events from the registered conduits for a specified
 amount of time.</div>
<p class="sec_header">Note:</p>This representation of timeout is not always accurate, so it is
 possible that the function will return with a timeout before the
 specified period.  For more accuracy, use the TimeSpan version.
<p class="sec_header">Note:</p>Implementers should define this method as:
 <pre class="d_code">
<span class="i">select</span>(<span class="i">TimeSpan</span>.<span class="i">interval</span>(<span class="i">timeout</span>));
</pre>
<p class="sec_header">Params:</p>
<table class="params">
<tr><td><em>timeout</em></td><td>the maximum amount of time in seconds that the
            selector will wait for events from the conduits; the
            amount of time is relative to the current system time
            (i.e. just the number of milliseconds that the selector
            has to wait for the events).</td></tr></table>
<p class="sec_header">Returns:</p>The amount of conduits that have received events; 0 if no conduits
 have received events within the specified timeout.</dd>
<dt class="decl">ISelectionSet <a class="symbol _function" name="ISelector.selectedSet" href="./htmlsrc/tango.io.selector.model.ISelector.html#L449" kind="function" beg="449" end="449">selectedSet</a><span class="params">()</span>; <span class="attrs">[<span class="prot">public</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#ISelector.selectedSet" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L449">#</a></dt>
<dd class="ddef">
<div class="summary">Return the selection set resulting from the call to any of the select()
 methods.</div>
<p class="sec_header">Remarks:</p>If the call to select() was unsuccessful or it did not return any
 events, the returned value will be null.</dd>
<dt class="decl">SelectionKey <a class="symbol _function" name="ISelector.key" href="./htmlsrc/tango.io.selector.model.ISelector.html#L459" kind="function" beg="459" end="459">key</a><span class="params">(ISelectable <em>conduit</em>)</span>; <span class="attrs">[<span class="prot">public</span>, <span class="stc">abstract</span>]</span> <a title="Permalink to this symbol" href="#ISelector.key" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.io.selector.model.ISelector.html#L459">#</a></dt>
<dd class="ddef">
<div class="summary">Return the selection key resulting from the registration of a conduit
 to the selector.</div>
<p class="sec_header">Remarks:</p>If the conduit is not registered to the selector the returned
 value will be null. No exception will be thrown by this method.</dd></dl></dd></dl>
</div>
<div id="footer">
  <p>Copyright (c) 2006 Juan Jose Comellas. All rights reserved</p>
  <p>Page generated by <a href="http://code.google.com/p/dil">dil</a> on Fri Dec 26 04:04:02 2008. Rendered by <a href="http://code.google.com/p/dil/wiki/Kandil">kandil</a>.</p>
</div>
</body>
</html>